package com.div.tools.popup

import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.div.tools.R

class PopupWindowActivity: AppCompatActivity(){
    private val FULL_SCREEN_FLAG = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        hideNav()
        setContentView(R.layout.activity_popup_window)
    }

    private fun hideNav() {
        window?.decorView?.systemUiVisibility = FULL_SCREEN_FLAG
    }

    fun top(view: View) {
        var inflate = LayoutInflater.from(this).inflate(R.layout.layout_popup_window, null)
        PopupTool.setContentView(this, inflate)
                .setBackgroundDrawable(ColorDrawable(Color.LTGRAY))
                .setFocusable(true)
                .setOutsideTouchable(true)
                .setAtFullScreen(true)
                .showAlpha(true)
                .showAtLocation(view, PopupTool.TOP)

    }

    fun left(view: View) {
        var inflate = LayoutInflater.from(this).inflate(R.layout.layout_popup_window, null)
        PopupTool.setContentView(this, inflate)
                .setFocusable(true)
                .setOutsideTouchable(true)
                .setAtFullScreen(true)
                .showAtLocation(view, PopupTool.LEFT)

    }

    fun right(view: View) {
        var inflate = LayoutInflater.from(this).inflate(R.layout.layout_popup_window, null)
        PopupTool.setContentView(this, inflate)
                .setFocusable(true)
                .setOutsideTouchable(true)
                .setAtFullScreen(true)
                .showAtLocation(view, PopupTool.RIGHT)

    }

    fun bottom(view: View) {
        var inflate = LayoutInflater.from(this).inflate(R.layout.layout_popup_window, null)
        PopupTool.setContentView(this, inflate)
                .setFocusable(true)
                .setOutsideTouchable(true)
                .setAtFullScreen(true)
                .showAtLocation(view, PopupTool.BOTTOM)
//                .showAsDropDown(view)
    }
}